package com.wyz.saas.common.set

import com.wyz.saas.common.utils.otherwise
import com.wyz.saas.common.utils.yes

abstract class AbstractAppSetDescriptorBoolean : AbstractAppSetDescriptor<Boolean>() {
    override fun default(): Boolean {
        return false
    }

    open fun getValueTip(value : Boolean): String{
        return value.yes { "打开" }.otherwise { "关闭" }
    }

    override fun validate(value: Any?): Boolean {
        if(value != null){
            if (value is String) {
                value.equals("true", ignoreCase = true).yes {
                    return true
                }.otherwise {
                    value.equals("false", ignoreCase = true).yes {
                        return true
                    }
                }
            } else if (value is Boolean) {
                return true
            }
        }
        return false
    }
}